<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>

        <script src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>

        <script>
            $(function(){

                $("a").click(function(){

                    $("#codeImage").prop("src","${pageContext.request.contextPath}/code/getImage?n="+new Date().getTime());



                });

                $("#code").blur(function(){
                    $.ajax({
                        url:"${pageContext.request.contextPath}/code/validateCode",
                        data:{"code":$(this).val()},
                        success:function(message){
                            $("#codeMessage").text(message);
                        }
                    });
                });

            });
        </script>

    </head>
    <body>
        <a href="javascript:;"><img id="codeImage" src="${pageContext.request.contextPath}/code/getImage"></a>
        <a href="javascript:;">换一张</a>
        <input type="text" id="code" name="code" size="5"/>
        <span id="codeMessage"></span>
    </body>
</html>
